package com.qingke.dao;

import java.io.InputStream;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;



public class MySqlSessionFactory 
{
	private SqlSessionFactory ssf;
	private static MySqlSessionFactory msf;
	private MySqlSessionFactory(InputStream in)
	{
		ssf=new SqlSessionFactoryBuilder().build(in);
	}
	public static MySqlSessionFactory getInstance()
	{
		if(msf==null)
		{
			synchronized (MySqlSessionFactory.class) {
				if(msf==null)
				{
					InputStream in=MySqlSessionFactory.class.getClassLoader().getResourceAsStream("sqlMapConfig.xml");
					return new MySqlSessionFactory(in);
				}
				
			}	
		}
		return msf;
		
	}
	public SqlSession getSession()
	{
		return ssf.openSession();
	}

}
